home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / util2 / pgp22src.zip / CONTRIB / ELM_NN / POSTPGP < prev    next >
Text File  |  1993-03-07  |  1KB  |  50 lines

  1. #!/usr/bin/perl
  2.  
  3. # written by jason steiner, jsteiner@anwsun.phya.utoledo.edu, Jan 1993
  4. #
  5. # if you use or make improvements to this program i would appreciate
  6. # copies of your modifications & your PGP public key.
  7.  
  8. ($visual = $ENV{'VISUAL'}) || ($visual = '/usr/ucb/vi');
  9. system($visual,@ARGV);
  10. while (!$q) {
  11.         print "Sign this message? [Y]: ";
  12.         $q = <STDIN>;
  13.     $q =~ s/[ \t\n]//g;
  14.     $q = substr ($q, 0, 1);
  15.         if (($q eq 'Y') || ($q eq 'y') || ($q eq '')) {
  16.                 push(@opts,'-st','+clearsig=on');
  17.                 $q = "y";
  18.         } elsif (($q ne 'N') && ($q ne 'n')) {
  19.                 $q = '';
  20.         }
  21. }
  22. if (@opts) {
  23.         $name = $ARGV[$#ARGV];
  24.     umask(077);
  25.         open(INPUT,$name);
  26.         open(HEAD,">${name}.head");
  27.         open(BODY,">${name}.body");
  28.         while (<INPUT>) {
  29.                 if (1 .. /^$/) {
  30.                         print HEAD;
  31.             if (m/^From: / || m/^To: / || m/^Date: /) {
  32.                 print BODY;
  33.             }
  34.                 } else {
  35.                         print BODY;
  36.                 }
  37.         }
  38.         close(HEAD);
  39.         close(BODY);
  40.         system('pgp','-a',@opts,"${name}.body");
  41.     if ($? == 0) {
  42.             unlink($name);
  43.             system "cat ${name}.head ${name}.body.asc > $name";
  44.     }
  45.         unlink("${name}.head");
  46.         unlink("${name}.body");
  47.         unlink("${name}.body.asc");
  48. }
  49.  
  50.